home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Libraries / Effect library / Demo ƒ / MSG Shell ƒ / msg environment.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-01-12  |  2.8 KB  |  110 lines  |  [TEXT/KAHL]

  1. /**********************************************************************\
  2.  
  3. File:        msg environment.c
  4.  
  5. Purpose:    This module handles initializing the environment and
  6.             checking for various environmental characteristics.
  7.  
  8.  
  9. MSG Demo -- graphic effects demonstration program
  10. Copyright (C) 1992-4 Mark Pilgrim & Dave Blumenthal
  11.  
  12. This program is free software; you can redistribute it and/or modify
  13. it under the terms of the GNU General Public License as published by
  14. the Free Software Foundation; either version 2 of the License, or
  15. (at your option) any later version.
  16.  
  17. This program is distributed in the hope that it will be useful,
  18. but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20. GNU General Public License for more details.
  21.  
  22. You should have received a copy of the GNU General Public License
  23. along with this program in a file named "GNU General Public License".
  24. If not, write to the Free Software Foundation, 675 Mass Ave,
  25. Cambridge, MA 02139, USA.
  26.  
  27. \**********************************************************************/
  28.  
  29. #include "GestaltEqu.h"
  30. #include "msg environment.h"
  31. #include "msg apple events.h"
  32. #include "msg graphics.h"
  33. #include "msg menus.h"
  34. #include "program globals.h"
  35.  
  36. Boolean            gHasColorQD;
  37. Boolean            gHasAppleEvents;
  38. Boolean            gHasFSSpecs;
  39. Boolean            gStandardFile58;
  40.  
  41. Boolean            gIsInBackground;
  42. Boolean            gInProgress;
  43. Boolean            gDone;
  44. Boolean            gDisableQuit;
  45.  
  46. Rect            gDragRect;
  47. Rect            gSizeRect;
  48.  
  49. void CheckEnvironment(void)
  50. {
  51.     long    gestalt_temp;
  52.     OSErr    isHuman;
  53.     
  54.     isHuman = Gestalt(gestaltQuickdrawVersion, &gestalt_temp);
  55.     gHasColorQD = !(isHuman || (gestalt_temp < gestalt8BitQD));
  56.     
  57.     GetMainScreenBounds();
  58.     
  59.     isHuman = Gestalt(gestaltFSAttr, &gestalt_temp);
  60.     gHasFSSpecs=((isHuman==noErr) && (gestalt_temp & (1 << gestaltHasFSSpecCalls)));
  61.  
  62.     gHasAppleEvents=0;
  63.     isHuman = Gestalt(gestaltAppleEventsAttr, &gestalt_temp);
  64.     if(!isHuman)
  65.     {
  66.         gHasAppleEvents = 1;
  67.         SetUpAppleEvents();
  68.     }
  69. }
  70.  
  71. void InitEnvironment(void)
  72. {
  73.     Handle        MBARHandle;
  74.     int            i;
  75.     
  76.     MBARHandle = GetNewMBar(400);
  77.     SetMenuBar(MBARHandle);
  78.     gAppleMenu = GetMHandle(appleMenu);
  79.     gFileMenu = GetMHandle(fileMenu);
  80.     gEditMenu = GetMHandle(editMenu);
  81.     gWipesMenu = GetMHandle(wipesMenu);
  82.     gAdditionsMenu = GetMHandle(additionsMenu);
  83.     gScrollMenu = GetMHandle(scrollMenu);
  84.     gFluffMenu = GetMHandle(fluffMenu);
  85.     
  86.     gHelpMenu = GetMenu(helpMenu);
  87.     gCrashMenu = GetMenu(crashMenu);
  88.     InsertMenu(gHelpMenu, -1);
  89.     InsertMenu(gCrashMenu, -1);
  90.     
  91.     AddResMenu(gAppleMenu, 'DRVR');
  92.     AdjustMenus();
  93.     DrawMenuBar();
  94.     
  95.     gNumHelp=CountMItems(gHelpMenu);
  96.     
  97.     gDragRect = screenBits.bounds;
  98.     gDragRect.top += 4;
  99.     gDragRect.left += 4;
  100.     gDragRect.right -= 4;
  101.     gDragRect.bottom -= 4;
  102.     
  103.     gDone=FALSE;
  104.     gDisableQuit=FALSE;
  105.     gIsInBackground=FALSE;
  106.     
  107.     if (gIsReversed)
  108.         ReverseAllWipes();
  109. }
  110.